package com.ruiysoft.security.entity;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * Created by 化增光 on 2018/5/9.
 */
public class IUserDetails implements UserDetails {
    private static final long serialVersionUID = 500L;
    private final String username;
    private final String password;
    private final Collection<? extends GrantedAuthority> authorities;
    private final boolean enabled;

    private final Long personnelId;
    private final Long userId;

    /**
     * 1代表小程序，0代表PC
     */
    private final int loginType;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return enabled;
    }

    public IUserDetails(String username, String password, Long userId,Long personnelId,Collection<? extends GrantedAuthority> authorities, boolean enabled, int loginType) {
        this.username = username;
        this.password = password;
        this.authorities = authorities;
        this.enabled = enabled;
        this.personnelId = personnelId;
        this.loginType = loginType;
        this.userId = userId;
    }

    public Long getPersonnelId() {
        return personnelId;
    }

    public int getLoginType() {
        return loginType;
    }

    public Long getUserId() {
        return userId;
    }
}
